package com.fastloan.mgt.product.enums;

/**
 * Created by gelon on 2017/11/16.
 */
public class ProductEnumSet {

    public enum RepayType {

        EQ_PRINCIPAL(0, "等额本金"),
        REPAYMENT_DUE(1, "到期还本付息"),
        EQ_PRINCIPAL_INTEREST(2, "等额本息"),
        PAY_INTEREST_DUE_PRINCIPAL(3, "按月付息到期还本");
        Integer code;
        String name;

        public void setCode(Integer code) {
            this.code = code;
        }

        public Integer getCode() {
            return this.code;
        }

        public void setName() {
            this.name = name;
        }

        public String getName() {
            return this.name;
        }

        RepayType(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public String jsonStr(Object param) {
            if (param instanceof String) {
                return "\"" + param + "\"";
            } else {
                return param.toString();
            }
        }

        public String toString() {
            return "{\"code\":" + jsonStr(code) + ",\"name\":" + jsonStr(name) + "}";
        }


        public static RepayType getValueToString(Integer repayType) {
            switch (repayType) {
                case 0:
                    return EQ_PRINCIPAL;
                case 1:
                    return REPAYMENT_DUE;
                case 2:
                    return EQ_PRINCIPAL_INTEREST;
                case 3:
                    return PAY_INTEREST_DUE_PRINCIPAL;
                default:
                    throw new RuntimeException("未找到对应类型");
            }
        }
    }

}
